<%--
  Created by IntelliJ IDEA.
  User: Dell
  Date: 2022/7/29
  Time: 9:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String basePath = request.getScheme()
            + "://" + request.getServerName()
            + ":" + request.getServerPort()
            + request.getContextPath() + "/";
%>
<html>
<head>
    <title>查询申请登记</title>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

    <jsp:include page="/resources/v2/webui.jsp">
        <jsp:param name="UIS" value="FORM_LAYER_BTN_LAYOUT"/>
    </jsp:include>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <script type="text/javascript" src="<%=basePath%>/static/js/plupload-master/js/plupload.full.min.js"></script>
    <script type="text/javascript" src="<%=basePath%>/static/js/application.js"></script>
    <script type="text/javascript" src="<%=basePath%>/static/js/publicJs.js"></script>

    <script>

        var type = "${type}";
        var ckxzes = ${ckxzes};
        var xzdw = ${xzdw};
        var fileListIndex = 0;
        var deleteSavedFileList = [];

        //存储文件对象数组
        var wjList = [];
        if(type !== "add") {
            wjList = ${jzs};
        }
        var contextPath = "${pageContext.request.contextPath}";

        $(function () {

            loadFrame(type, ckxzes);

            uploader.init();

            setChecked(xzdw);

            if (type === "view") {
                setDisabled();
            }
        });

    </script>
</head>
<body>
<div class="body_wrap">
    <table class="tdh_form" style="height: 100%;">
        <colgroup>
            <col width="2%"/>
            <col width="98%"/>
        </colgroup>
        <tr>
            <td colspan="2" align="left">
                <a class="tdh_btn tdh_btn_blue" onclick="saveTable(10)">保存</a>
                <a class="tdh_btn tdh_btn_blue" onclick="sendFile()">发送</a>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <div class="tdh_form_title"> 司法查询登记表</div>
            </td>
        </tr>
        <tr>
            <td class="tdTitle" rowspan="2" style="padding-left: 10px;">查询对象</td>
            <td class="tdCont">
                <input type="hidden" id="djpc"/>
                <div class="fixed_layout_c" id="divQueryObj" style="max-height: 340px; overflow-y: scroll"></div>
            </td>
        </tr>
        <tr>
            <td align="right">
                <a class="tdh_btn tdh_btn_blue" onclick="addFrame()">新增</a>
                <a class="tdh_btn tdh_btn_blue" onclick="removeFrame()">删除</a>
            </td>
        </tr>
        <tr>
            <td class="tdTitle">协执单位</td>
            <td class="tdCont">
                <table class="tdh_table" id="companyTable">
                    <colgroup>
                        <col width="15%"/>
                        <col width="85%"/>
                    </colgroup>
                    <tr>
                        <td colspan="2">
                            <label><input class="inputCheck" type="checkbox" id="companyAll" onchange="checkAll(this)"/>所有单位(选择下列单位发起财产查询通知, 至少选择一个协助执行单位)</label>
                        </td>
                    </tr>

                    <c:forEach items="${companyMap}" var="map" varStatus="mapStatus">
                        <tr>
                            <td>
                                <label><input class="inputCheck companyKind" type="checkbox" onchange="checkRow(this)" value="${map.value.get(0).xzdwfl}"/>${map.key}</label>
                            </td>
                            <td>
                                <c:forEach items="${map.value}" var="company" varStatus="status">
                                    <div style="display:inline-block;width: 120px;padding: 10px">
                                        <input class="inputCheck companyEach" type="checkbox" onchange="checkKind(this)" value="${company.xzdwdm}"/>${company.mc}
                                    </div>
                                    <c:if test="${(status.index+1)%3==0}">
                                        <br/>
                                    </c:if>
                                </c:forEach>
                            </td>
                        </tr>
                    </c:forEach>
                </table>
            </td>
        </tr>
        <tr>
            <td class="tdTitle">协执说明</td>
            <td class="tdCont" colspan="5">
                <textarea class="inputArea" id="xzsm"></textarea>
            </td>
        </tr>
        <tr>
            <td class="tdTitle">文书信息</td>
            <td class="tdCont" colspan="5">
                <div style="display: flex; justify-content: right">
                    <a class="tdh_btn tdh_btn_blue" id="uploadBtn">上传</a>
                    <a class="tdh_btn tdh_btn_blue" onclick="delFile()">删除</a>
                </div>
                <div id="allFile">
                </div>
            </td>
        </tr>
    </table>
</div>
</body>

<script>

    //文件上传
    var uploader = new plupload.Uploader({          //实例化上传对象
        browse_button: 'uploadBtn',                 //上传按钮id
        url: CONTEXT_PATH + '/ck/uploadFile',       //上传路径
        multipart: true,                            //是否文件上传
        multi_selection: false,                     //是否允许选取多个
        max_file_size: '10mb',                      //最大文件限制
        filters: [                                  //指定要浏览的文件类型
            {
                title: "files",
                extensions: "pdf,doc,docx"
            }
        ],
        init: {
            FilesAdded: function(up, file) {

                //选择完后直接上传
                uploader.start();
            },

            //文件上传完毕触发
            FileUploaded:
                function(up, file, info) {
                var result = eval('(' + info.response + ')');
                if(result.code === 200) {
                    var data = result.data;
                    var fileOriginName = data.originName;

                    // 新文件名
                    var wj = {};
                    wj.wjmc = data.saveName;
                    wj.path = data.realPath;
                    wj.wjlx = data.fileType;
                    wj.djpc = $("#djpc").val();

                    wjList.push(wj);

                    //表中放入文件图标和名称
                    var imgSrc = "";
                    if (wj.wjlx === 'pdf') {
                        imgSrc = CONTEXT_PATH + "/static/images/pdf.PNG";
                    } else {
                        imgSrc = CONTEXT_PATH + "/static/images/doc.PNG";
                    }
                    var path = wj.path.replace(/\\/g, '\\\\');
                    var wholePath = path + "\\\\" + wj.wjmc;
                    var fileHtml = "<div class='fileDiv'>" +
                            "<input class='inputCheck isNewFile' type='checkbox' value='" + fileListIndex + "'/>" +
                            "<input type='hidden' class='wholePath' value='" + wholePath + "' />" +
                            "<img src=\"" + imgSrc + "\" alt='文件' title=\"点击下载查看\" onclick=\"downloadFile('" + wj.wjmc + "','" + path + "')\"/>" +
                            fileOriginName +
                        "</div>";
                    $("#allFile").append(fileHtml);
                    checkboxInit($(".fileDiv").find(".inputCheck"));
                    fileListIndex++;
                } else {
                    layer.msg(result.message);
                }
            },
            Error: function (up, err, file) {
                console.log("上传出错 ");
            }
        }
    });
</script>
</html>
